package com.cet.lxf.oop.test05;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * @program: algorithm
 * @description:
 * @author: 陈恩涛
 * @create: 2021-06-28 17:14
 **/
public class Main04 {
    public static void main(String[] args) {
        BigDecimal d1 = new BigDecimal("123.456789");
        // 四舍五入，123.4568
        BigDecimal d2 = d1.setScale(4, RoundingMode.HALF_UP);
        // 直接截断，123.4567
        BigDecimal d3 = d1.setScale(4, RoundingMode.DOWN);
        System.out.println(d2);
        System.out.println(d3);
    }
}
